/*
 * @Author: 肖思汗 
 * @Date: 2025-05-30 15:52:45 
 * @Last Modified by: 肖思汗
 * @Last Modified time: 2025-07-02 09:33:47
 */

import Api from "src/api/Api";
import { GoodsData } from "types/type";


//首页的接口
class IndexApi extends Api {

    constructor() {
        super();
    }

    //获取排序前8的商品一级分类菜单
    firstProductType() {
        return this._get("/homePage/firstProductType");
    }
    //获取所有的商品二级分类菜单
    secondProductType() {
        return this._get("/homePage/secondProductType");
    }
    //查询首页配置信息
    queryHomePageConfig() {
        return this._get("/homePage/queryHomePageConfig");
    }
    //查询热点商品
    async queryTopProductList(productTypeId: string) {
        const res = await this._get("/homePage/queryTopProductList", { productTypeId });
        (res.data as Array<GoodsData>).map(goods => {
            //@ts-ignore
            goods.productData = JSON.parse(goods.productData);
        });
        return res.data;
    }

}

const indexApi = new IndexApi();

export default indexApi;